package cn.yunhe.dao;

import cn.yunhe.util.BaseDB;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class AdminDao extends BaseDB implements IAdminDao {
    @Override
    public int searchUserByName(String name) {
        Connection conn=null;
        PreparedStatement ps=null;
        ResultSet rs=null;
        int result=0;
        conn=getConn();
        String sql="select * from t_admin where username=?";
        try {
            ps=conn.prepareStatement(sql);
            ps.setString(1,name);
            rs= ps.executeQuery();

            if(rs.next()){
                return  1;

            }
        } catch (SQLException e) {
            e.printStackTrace();
        }finally {
            closeAll(conn,ps,rs);
        }
        return result;
    }
}
